﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Superstore.Vender.PushMessage
{
    public class Message
    {
        public Message(string t, string c)
        {
            type = t;
            content = c;
        }
        public string type { get; set; }
        public string content { get; set; }
    }

    public class UserMessage
    {
        private string userId;
        private List<Message> messageList;
        private DateTime lastUpdate;

        public readonly static UserMessage EMPTY = new UserMessage("");
        public UserMessage(string id)
        {
            userId = id;
            messageList = new List<Message>();
            lastUpdate = DateTime.Now;
        }

        public string UserId { get { return userId; } }
        public DateTime LastUpdate { get { return lastUpdate; } }
        public string LastTick { get { return lastUpdate.ToLongDateString(); } }

        public bool IsEmpty()
        {
            return string.IsNullOrEmpty(userId);
        }

        public List<Message> GetMessages()
        {
            return messageList;
        }

        public void AddMessage(Message msg)
        {
            messageList.Add(msg);
            lastUpdate = DateTime.Now;
        }
    }
}